<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>javascript的数据类型</title>
  <script>
    let a =10;
    let str = "hello world";
    let str1 ="20";
    let b = parseInt(str1); // 将字符串转换为整数
    console.log(a+b); // 30
    console.log(a+str1);
    //一个是number，一个是string
    console.log(typeof(a),typeof(str1)); // hello world20

    let c = 22; // undefined
    console.log(c); // undefined
    let n = null;
    //undefined和null如果转换为boolean类型，都是false
    console.log(Boolean(c)); // false 
    console.log(Boolean(n)); // false
    //undefined和null的区别：undefined是变量声明了但是没有赋值，null是变量声明了并且赋值为null

    let arr = [10,20,30,40,50];//数组类型
    if(c) {
      console.log("c是true",c); // c是true
    } else {
      console.log("c是false"); // c是false
      
    }
    
  </script>
</head>
<body>
  
</body>
</html>